﻿package com.toncen.samepms.system.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.toncen.samepms.common.AbstractDatabaseAction;
import com.toncen.samepms.system.dao.ModuleConfigDao;
import com.toncen.samepms.system.domain.ModuleConfig;

/**
 * 描述：模块配置表表SYSTEM_MODULE_CONFIG的action文件
 * 
 * @author tch
 * 
 */
public class ModuleConfigAction  extends AbstractDatabaseAction<ModuleConfig, ModuleConfigDao>{
	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1339154025464L;

	public ModuleConfigAction() throws Exception{
		super();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.toncen.samepms.common.AbstractAction#prepareOnDoNew()
	 */
	@Override
	public void prepareOnDoNew() throws Exception {
		super.prepareOnDoNew();
		HttpServletRequest request = ServletActionContext.getRequest();
		String parentId = request.getParameter("domain.parentId");
		ModuleConfig m = new ModuleConfig();
		if(null!=parentId)
		{
			m.setParentId(Long.parseLong(parentId));
			setDomain(m);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.toncen.samepms.common.AbstractAction#prepareOnDoView()
	 */
	/*@Override
	public void prepareOnDoView() throws Exception {
		super.prepareOnDoView();
		getDomain().setParent(getDao().find(getDomain().getParent()));
	}*/

	/**
	 * 获取指定名称的编码
	 * 
	 * @param code
	 * @return
	 * @throws Exception
	 */
	public List<ModuleConfig> getRootModuleConfigList() throws Exception {
		ModuleConfigDao moduleConfigDao = new ModuleConfigDao();
		List<ModuleConfig> list = (List<ModuleConfig>) moduleConfigDao.getAllRootModuleConfig();
		
		return list;
	}

}
